import mockjs, { Random } from 'mockjs';

const phonePrefix = ['132', '135', '189']
const index = Math.floor(Math.random() * phonePrefix.length)

export default {
  'Post /tenant/tables': mockjs.mock({
    msg: '操作成功',
    code: 200,
    'data|100': [
      {
        'id|+1': 1,
        name: '@ctitle(5,7)',
        username: '@cname(2,3)',
        cityDesc: '@city',
        msg: "@cword(5,10)", // 随机段落
        remark: "@cword(5,10)", // 随机段落
        date: "@datetime", // 随机日期
        startDate: '@datetime',
        endDate: '@datetime',
        title: Random.title(),
        ip: Random.ip(),
        'number10｜1-10': 1,
        number: Random.id(),
        phone: phonePrefix[index] + mockjs.mock(/\d{8}/),
        state: "error",
        avatar: Random.image(),
        hasHandle: Random.boolean(),
        address: Random.region(),
        color: Random.color(),
        text: Random.paragraph(1, 20)
      }
    ],
    msg: "操作成功",
    code: 200
  }),
  'Post /tenant/tables/type': mockjs.mock({
    msg: '操作成功',
    code: 200,
    'data|3': [
      {
        'id|+1': 1,
        name: '@ctitle(5,7)',
        username: '@cname(2,3)',
        cityDesc: '@city',
        msg: "@cword(5,10)", // 随机段落
        remark: "@cword(5,10)", // 随机段落
        date: "@datetime", // 随机日期
        startDate: '@datetime',
        endDate: '@datetime',
        title: Random.title(),
        ip: Random.ip(),
        'number10｜1-10': 1,
        number: Random.id(),
        phone: phonePrefix[index] + mockjs.mock(/\d{8}/),
        state: "running",
        avatar: Random.image(),
        hasHandle: Random.boolean(),
        address: Random.region(),
        color: Random.color(),
        text: Random.paragraph(1, 20)
      }
    ],
    msg: "操作成功",
    code: 200
  }),

  // 'POST /api/login': mockjs.mock({
  //   msg: '操作成功',
  //   code: 200,
  //   'data|100': [
  //     {
  //       'id|+1': 1,
  //       name: 'foo',
  //       cityDesc: '@city',
  //       msg: "@cparagraph(2,3)", // 随机段落
  //       date: "@datetime", // 随机日期
  //       'number|+1': 1,
  //       text: Random.paragraph(30, 300)
  //     }
  //   ],
  //   msg: "操作成功",
  //   code: 200
  // })
}
